home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Softdisk Supreme
/
Softdisk Supreme.iso
/
pc
/
DSK Files
/
0-49
/
SD003b.dsk
/
FRACTION.MULTIPLIER.bas
< prev
next >
Wrap
BASIC Source File
|
2003-06-12
|
2KB
|
49 lines
0 HOME
1 REM FRACTION MULTIPLIER.
2 REM ANSWER=[FIRST INTEGER+(FIRST NUMERATOR/FIRST DENOMINATOR)]*[SECOND INTEGER+(SECOND NUMERATOR/SECOND DENOMINATOR)]
3 REM BY IAN PILCHER
10 INPUT "FIRST INTEGER: ";WA
20 INPUT "FIRST NUMERATOR: ";UA
21 QA = UA
30 INPUT "FIRST DENOMINATOR: ";DA
40 INPUT "SECOND INTEGER: ";WB
50 INPUT "SECOND NUMERATOR: ";UB
51 QB = UB
60 INPUT "SECOND DENOMINATOR: ";DB
70 UA = WA *DA +UA
80 UB = WB *DB +UB
90 UC = UA *UB
100 DC = DA *DB
110 IF UC < = DC THEN 150
120 WC = 0
130 UC = UC -DC:WC = WC +1
140 IF UC >DC THEN 130
150 FOR X = 2 TO INT( SQR(UC))
160 IF UC/X = INT(UC/X) AND DC/X = INT(DC/X) THEN UC = UC/X:DC = DC/X
170 NEXT X
180 IF DC/UC = INT(DC/UC) THEN DC = DC/UC:UC = 1
185 VTAB (12)
190 IF UC = DC THEN WC = WC +1: GOTO 220
200 POKE 36,4: PRINT QA;
201 POKE 36,15: PRINT QB;
202 POKE 36,26: PRINT UC
203 PRINT WA;: POKE 36,3: PRINT "--- X ";WB;: POKE 36,14: PRINT "--- = ";WC;: POKE 36,25: PRINT "-----"
204 POKE 36,4: PRINT DA;
205 POKE 36,15: PRINT DB;
206 POKE 36,26: PRINT DC
210 END
220 POKE 36,4: PRINT QA;
221 POKE 36,15: PRINT QB
223 PRINT WA;: POKE 36,3: PRINT "--- X ";WB;: POKE 36,14: PRINT "--- = ";WC
224 POKE 36,4: PRINT DA;
225 POKE 36,15: PRINT DB
230 END
240 REM LINES 0-60 INPUT NUMBERS
250 REM LINES 21,51 SAVE ORIGINAL NUMERATORS FOR LATER DISPLAY
260 REM LINES 70-80 CHANGE MIXED FRACTIONS TO IMPROPER FRACTIONS
270 REM LINES 90-100 MULTIPLY THE FRACTIONS
280 REM LINE 110 DETERMINES IF THE PRODUCT IS IMPROPER AND IF NOT JUMPS THE DE-MIXING ROUTINE
290 REM LINES 120-140 = DE-MIXING ROUTINE
300 REM LINES 150-180 MAKES SURE THE NUMERATOR AND DENOMINATOR ARE RELATIVELY PRIME
310 REM LINE 190 DETERMINES WHETHER THE NUMERATOR AND DENOMINATOR ARE EQUAL AND IF SO JUMPS TO AN ALTERNATE PRINT STATEMENT
320 REM LINES 200-230 PRINT THE ANSWER AND END THE PROGRAM